﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Mmht.BT;

public partial class admin_tzgl_tjtz : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["admin_id"] == null)
        {
            Response.Redirect("admin_logout.aspx");
            return;
        }
    }

    protected void btAdd_Click(object sender, EventArgs e)
    {
        int adminId = (Int32)Session["admin_id"];
        NoticeBT nb = new NoticeBT();
        DataTable dt = new DataTable();
        string name = this.tbTitle.Text;
        string notice = this.tbContent.Text;
        ContentValidate cv = new ContentValidate();
        name = cv.Process(name);
        notice = cv.Process(notice);
        bool emergency = false;
        string eg = this.DropDownList1.SelectedValue;
        if (eg == "1")
        {
            emergency = true;
        }
        bool rst = nb.InsertNotice(name, notice, emergency, adminId);
        string msg = string.Empty;
        if (rst)
        {
            msg = "发布通知成功";
            this.tbTitle.Text = "";
            this.tbContent.Text = "";
        }
        else
        {
            msg = "发布通知失败";
        }
        message_show(msg);
    }

    /// <summary>
    /// 信息提示
    /// </summary>
    /// <param name="msg">提示信息</param>
    private void message_show(string msg)
    {
        this.Page.ClientScript.RegisterStartupScript(this.GetType(), "信息提示", "<script language='javascript'>  warning('" + msg + "');</script>");
    }
}
